package com.code.family.entity.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * 收支类别枚举类
 * @author 上玄
 */
@Getter
public enum CategoryType {
    HOUSING(1, "住房"),
    HEALTHCARE(2, "医疗"),
    FOOD(3, "食品"),
    TRANSPORTATION(4, "交通"),
    DINING(5, "餐饮"),
    CLOTHING(6, "穿搭"),
    EDUCATION(7, "教育"),
    ENTERTAINMENT(8, "娱乐"),
    HAIR_SALON(9, "理发"),
    FINANCE(10, "理财");

    @EnumValue
    private final int value;
    @JsonValue
    private final String desc;

    CategoryType(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static CategoryType fromValue(int value) {
        for (CategoryType type : CategoryType.values()) {
            if (type.getValue() == value) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知的收支类别类型值: " + value);
    }
}